<?php
defined( 'BASEPATH' ) or exit( 'No direct script access allowed' );
class Location
{
    private $data = array ();
    function __construct($root_option = array())
    {
        $this->data[0] = array (
                'title' => '首页',
                'url' => 'index',
                'link' => '',
                'icon' => '' 
        );
        foreach ( $this->data[0] as $k => $v )
        {
            if (isset( $root_option[$k] ))
            {
                $this->data[0][$k] = $root_option[$k];
            }
        }
    }
    function add($title = '', $url = '#', $link = '>', $icon = '', $level = null)
    {
        if ($level === null)
        {
            $level = count( $this->data );
        }
        $this->data[$level] = array (
                'title' => $title,
                'url' => $url,
                'link' => $link,
                'icon' => $icon 
        );
    }
    function get_data()
    {
        ksort( $this->data );
        return $this->data;
    }
}